<?php

	function get_object_by_description($descr)
	{
		global $CONFIG;
		
		$query = "SELECT e.* from {$CONFIG->dbprefix}entities e join {$CONFIG->dbprefix}objects_entity o on e.guid=o.guid where description=\"{$descr}\" limit 0, 1";
		$row = get_data_row($query);
		if ($row)
			return new ElggObject($row);
		else
			return false;
	}

	
	function digg_init()
	{
		global $CONFIG;
		
		register_page_handler('digg','digg_page_handler');
		
		extend_view('css','digg/css');
		
		if (isloggedin()) {
			extend_view('owner_block/extend', 'digg/digg_this');

			// Set up menu for logged in users
			add_menu("Diggs", $CONFIG->wwwroot . "pg/digg/");
		}

		register_action('digg/submit', false, $CONFIG->pluginspath . "digg/actions/submit.php");		
	}
	
	
	function digg_page_handler($page) 
	{
		global $CONFIG;
		
		if ($page[0])
		{
			switch ($page[0])
			{
				case "view":
					if (isset($page[1])) set_input('digg_guid',$page[1]);
					include($CONFIG->pluginspath . "digg/pages/view.php");
					break;
			}
		}
		else
			include($CONFIG->pluginspath . "digg/pages/index.php"); 
	}
	
	
	
	register_elgg_event_handler('init','system','digg_init');
	
?>